package cn.fl.project.controller;

import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.alibaba.fastjson.JSONObject;

import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.KeyValueVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.mid.core.framework.page.Pager;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.customer.vo.CstBscInfoVO;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.project.condition.PrjCstProfitAnaQueryCondition;
import cn.fl.project.constant.PrjCstBscInfoConstant;
import cn.fl.project.service.IPrjBscInfoService;
import cn.fl.project.service.IPrjCstProfitAnaService;
import cn.fl.project.service.IPrjCstRepayAbiService;
import cn.fl.project.vo.PrjCstProfitAnaVO;
import cn.fl.project.vo.PrjCstRepayAbiVO;
import cn.fl.system.constant.SysLogConstant;

/**
 * @Description: 收益分析表 控制层
 */
@Controller
@RequestMapping("/project/prjcstprofitana")
public class PrjCstProfitAnaController extends BaseController {
	private static final Logger logger = LoggerFactory.getLogger(PrjCstProfitAnaController.class);

	/**
	 * PrjCstProfitAna 服务层BEAN
	 */
	@Autowired
	private IPrjCstProfitAnaService prjCstProfitAnaService;

	/**
	 * prjBscInfoService 服务层BEAN
	 */
	@Autowired
	private IPrjBscInfoService prjBscInfoService;
	
	

	/**
	 * prjCstRepayAbiService 服务层BEAN
	 */
	@Autowired
	private IPrjCstRepayAbiService prjCstRepayAbiService;
	/**
	 * 到列表页面
	 */
	@RequestMapping(value = "/toAddPage.do", method = { RequestMethod.GET})
	public ModelAndView toListPage(HttpServletRequest request, HttpServletResponse response) {
		String prjId = request.getParameter("prjId");
		String detailFlag = request.getParameter("detailFlag");
		String cstRlCd = request.getParameter("cstRlCd");// 客户类型
		Long cstId =null;
		String cstType = "";
		PrjCstRepayAbiVO  abi = null;
		if(StringUtils.isNotBlank(prjId)){
			CstBscInfoVO cst = 	this.prjBscInfoService.getCstTypByPrjId(Long.valueOf(prjId));
			if(null!=cst){
				cstId = cst.getId();
				cstType = cst.getCstTypCd();
			}
		}
		PrjCstProfitAnaVO profit  = null;
		
		List<KeyValueVO> keyList = this.prjBscInfoService.getPrjApyCrdtList();//信用记录
		List<KeyValueVO> YesNoList = this.prjBscInfoService.getYesNoList();//是否列表
		if(StringUtils.isNotBlank(prjId)&&null!=cstId){
			profit = this.prjCstProfitAnaService.getPrjCstProfitAnaByPrjIdAndCstId(Long.valueOf(prjId),cstId);//通过项目和客户id查询客户调查报告
		}
		//查询还款能力表中字段信息
		if(StringUtils.isNotBlank(cstRlCd)&&cstRlCd.equals(PrjCstBscInfoConstant.CST_Rl_ATTR_TENANT)){
			abi = this.prjCstRepayAbiService.getPrjCstRepayAbiByPrjIdAndCstId(Long.valueOf(prjId), cstId, cstRlCd);
		}
		ModelAndView view = new ModelAndView("project/prjcstprofitana/prjcstprofitanaAdd");
		view.addObject("prjId", prjId);
		view.addObject("cstId", cstId);
		view.addObject("profit", profit);
		view.addObject("keyList",keyList);
		view.addObject("cstType", cstType);
		view.addObject("YesNoList", YesNoList);
		view.addObject("detailFlag", detailFlag);
		view.addObject("abi", abi);
		view.addObject("cstRlCd", cstRlCd);
		BaseLogUtils.info(logger, "toListPage", "跳转到列表页面.", CurrentThreadContext.getCurrentUserName());
		return view;
	}

	/**
	 * 到修改页面
	 */
	@RequestMapping(value = "/toModifyPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toModifyPage(HttpServletRequest request, HttpServletResponse response) {
		String id = request.getParameter("id");
		ModelAndView view = new ModelAndView("project/prjCstProfitAna/modify");
		view.addObject("id", id);
		BaseLogUtils.info(logger, "toModifyPage", "跳转到修改页面.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
		return view;
	}

	/**
	 * 初始化列表
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/initList.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object initList(HttpServletRequest request, HttpServletResponse response) {
		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		String searchName = request.getParameter("demo.name");
		Pager page = new Pager();
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.parseInt(currentPage));
		}

		if (StringUtils.isNotEmpty(currentPage)) {
			page.setEveryPage(Integer.parseInt(pageSize));
		}

		PrjCstProfitAnaQueryCondition qc = new PrjCstProfitAnaQueryCondition();
		if (StringUtils.isNotEmpty(searchName)) {
			//TODO SOMTHING
		}
		page.setCondition(qc);

		//TODO SOMETHING
		Pager pager =  this.prjCstProfitAnaService.searchListPage(page);
		List<PrjCstProfitAnaVO> list = (List<PrjCstProfitAnaVO>) pager.getResultList();
		ListPageVO<PrjCstProfitAnaVO> listPage = new ListPageVO<PrjCstProfitAnaVO>(list, pager.getTotalCount());
		BaseLogUtils.info(logger, "initList", "查询数据完成. DATA:" + JSONObject.toJSONString(page), CurrentThreadContext.getCurrentUserName());
		return listPage;
	}

	/**
	 * 删除数据
	 */
	@RequestMapping(value = "/removeById.do", method = {RequestMethod.POST })
	@ResponseBody
	public DataResultVO removeById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_DELETE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			return result;
		}
		try {
			this.prjCstProfitAnaService.removeById(Long.valueOf(id));
			BaseLogUtils.info(logger, "removeById", "删除数据.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "removeById", "删除数据失败.[id="+id+"]"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "removeById", "删除数据失败.[id="+id+"]"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}

		return result;
	}

	/**
	 * 得到一条记录
	 * 
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getById.do", method = { RequestMethod.GET})
	@ResponseBody
	public Object getById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_OPERATE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.error(logger, "getById", "获取数据,主键不存在.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		
		try {
			PrjCstProfitAnaVO vo = this.prjCstProfitAnaService.selectById(Long.valueOf(id));
			if(null == vo){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_QUERY_DATA_IS_EMPTY);
				BaseLogUtils.info(logger, "getById", "获取数据,数据不存在.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
			}
			result.setData(vo);
			BaseLogUtils.info(logger, "getById", "获取数据.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
		}catch(BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "getById", "获取失败.[id="+id+"]"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch(Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "getById", "获取失败.[id="+id+"]"+ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}

	/**
	 * 新增
	 */
	@RequestMapping(value = "/add.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object add(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String rptId = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_ADD_SUCC);
		PrjCstProfitAnaVO entity = null;
		Long id = null;
		try {
			PrjCstProfitAnaVO prjCstProfitAnaVO = getPrjCstProfitAnaParam(request);
			if(StringUtils.isNotBlank(rptId)){
				//修改客户调查报告
				prjCstProfitAnaVO.setId(Long.valueOf(rptId));
				this.prjCstProfitAnaService.modify(prjCstProfitAnaVO);
				result.setSuccess(BaseConstant.IS_YESNO_YES);
				result.setInfo(SysLogConstant.LOG_CMM_UPDATE_SUCC);
				id=Long.valueOf(rptId);
			}else{
				//获取页面参数
				prjCstProfitAnaVO.setCrtTm(new Date());
				prjCstProfitAnaVO.setCrtUsrId(CurrentThreadContext.getCurrentUserId());
				prjCstProfitAnaVO.setIsDel(BaseConstant.IS_YESNO_NO);
				 id = this.prjCstProfitAnaService.add(prjCstProfitAnaVO);
			}
			result.setData(id);
			BaseLogUtils.info(logger, "add", "新增数据.[id="+id+"] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "add", "新增数据失败.DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "add", "新增数据失败.DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}

		return result;
	}

	private PrjCstProfitAnaVO getPrjCstProfitAnaParam(HttpServletRequest request) {
		PrjCstProfitAnaVO profit = new PrjCstProfitAnaVO();
		String prjId = request.getParameter("prjId");//项目id
		String cstId = request.getParameter("cstId");//客户id
		String drftOptLine = request.getParameter("drftOptLine");//拟运营线路
		String drftOptDist = request.getParameter("drftOptDist");//拟运营距离
		String monRoundTm = request.getParameter("monRoundTm");//月往返趟数
		String settCyl = request.getParameter("settCyl");//结算周期
		String shpmetToDist = request.getParameter("shpmetToDist");//运输货物-去程
		String shpmetCmDist = request.getParameter("shpmetCmDist");// 运输货物-回程
		String loadWegtToDist = request.getParameter("loadWegtToDist");//载重量（吨）-去程
		String loadWegtCmDist = request.getParameter("loadWegtCmDist");//载重量（吨）-回程
		String frgtLvlToDist = request.getParameter("frgtLvlToDist");//运费水平（元）-去程
		String frgtLvlCmDist = request.getParameter("frgtLvlCmDist");//运费水平（元）-回程
		String drvrWage = request.getParameter("drvrWage");//过路过桥费（元）
		String fuelCost = request.getParameter("fuelCost");//FUEL_COST
		String monPrem = request.getParameter("monPrem");// 月保险费（元）
		String maintCost = request.getParameter("maintCost");//维修保养费用（元）
		String othCost = request.getParameter("othCost");//OTH_COST
		String monNetIncm = request.getParameter("monNetIncm");// 月净收入（元）
		String totalMonIncm = request.getParameter("totalMonIncm");//  月收入合计（元）
		String totalMonExpdtr = request.getParameter("totalMonExpdtr");// 月支出合计（元）
		String monRpmtAmt = request.getParameter("monRpmtAmt");// 月均还款金额（元）
		String monIncmExpdtrRatio = request.getParameter("monIncmExpdtrRatio");//  每月收入支出比例
		String localInduAnal = request.getParameter("localInduAnal");// 当地行业现状分析
		String equipOptBrifDesc = request.getParameter("equipOptBrifDesc");// 设备运营环境简要描述
		String hgwyLowEfmtDesc = request.getParameter("hgwyLowEfmtDesc");// 路政执法情况简述
		String rymtSourGuar = request.getParameter("rymtSourGuar");//  还款来源与保障
		String riskCtlMeas = request.getParameter("riskCtlMeas");// 风险控制措施
		String isCrimRecd = request.getParameter("isCrimRecd");// 是否有犯罪记录或诉讼案件
		String isFinaInstAss = request.getParameter("isFinaInstAss");// 是否曾经被金融机构执行资产
		String apyCrdtCd = request.getParameter("apyCrdtCd");// 申请企业我司信用记录
		String corpReprCrdtCd = request.getParameter("corpReprCrdtCd");// 法人代表我司信用记录
		String toll = request.getParameter("toll");//燃油费
		String analMonIncm = request.getParameter("analMonIncm");//同业人员类比月收入(元)
		String cstRlCd = request.getParameter("cstRlCd");//客户关系
		if(StringUtils.isBlank(drftOptLine)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		if(StringUtils.isBlank(drftOptDist)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		if(StringUtils.isBlank(monRoundTm)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		if(StringUtils.isBlank(settCyl)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		if(StringUtils.isBlank(shpmetToDist)){		
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		if(StringUtils.isBlank(shpmetCmDist)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		if(StringUtils.isBlank(loadWegtToDist)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		if(StringUtils.isBlank(loadWegtCmDist)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		if(StringUtils.isBlank(frgtLvlToDist)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		if(StringUtils.isBlank(frgtLvlCmDist)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		if(StringUtils.isBlank(drvrWage)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		if(StringUtils.isBlank(fuelCost)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		if(StringUtils.isBlank(monPrem)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		if(StringUtils.isBlank(maintCost)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		if(StringUtils.isBlank(monNetIncm)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		if(StringUtils.isBlank(totalMonIncm)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		if(StringUtils.isBlank(totalMonExpdtr)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		if(StringUtils.isBlank(monRpmtAmt)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		if(StringUtils.isBlank(monIncmExpdtrRatio)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		if(StringUtils.isBlank(localInduAnal)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		if(StringUtils.isBlank(equipOptBrifDesc)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		if(StringUtils.isBlank(hgwyLowEfmtDesc)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		if(StringUtils.isBlank(rymtSourGuar)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		if(StringUtils.isBlank(riskCtlMeas)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		if(StringUtils.isBlank(othCost)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		if(StringUtils.isBlank(toll)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		
		if(StringUtils.isBlank(analMonIncm)){
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		profit.setCstRlCd(cstRlCd);
		profit.setAnalMonIncm(analMonIncm);
		if(StringUtils.isNotBlank(isCrimRecd)){
			profit.setIsCrimRecd(Integer.valueOf(isCrimRecd));
		}
		if(StringUtils.isNotBlank(isFinaInstAss)){
			profit.setIsFinaInstAss(Integer.valueOf(isFinaInstAss));
		}
			profit.setApyCrdtCd(apyCrdtCd);
			profit.setCorpReprCrdtCd(corpReprCrdtCd);
		if(StringUtils.isNotBlank(prjId)){
			profit.setPrjId(Long.valueOf(prjId));
		}
		if(StringUtils.isNotBlank(cstId)){
			profit.setCstId(Long.valueOf(cstId));
		}
		profit.setDrftOptLine(drftOptLine);
		profit.setDrftOptDist(drftOptDist);
		profit.setMonRoundTm(monRoundTm);
		profit.setSettCyl(settCyl);
		profit.setShpmetToDist(shpmetToDist);
		profit.setShpmetCmDist(shpmetCmDist);
		profit.setLoadWegtToDist(loadWegtToDist);
		profit.setLoadWegtCmDist(loadWegtCmDist);
		profit.setToll(toll);
		profit.setFrgtLvlToDist(frgtLvlToDist);
		profit.setFrgtLvlCmDist(frgtLvlCmDist);
		profit.setDrvrWage(drvrWage); 
		profit.setFuelCost(fuelCost); 
		profit.setMonPrem(monPrem);
		profit.setMaintCost(maintCost);
		profit.setOthCost(othCost);
		profit.setMonNetIncm(monNetIncm);
		profit.setTotalMonIncm(totalMonIncm);
		profit.setTotalMonExpdtr(totalMonExpdtr);
		profit.setMonRpmtAmt(monRpmtAmt);
		profit.setMonIncmExpdtrRatio(monIncmExpdtrRatio);
		profit.setLocalInduAnal(localInduAnal);
		profit.setEquipOptBrifDesc(equipOptBrifDesc);
		profit.setHgwyLowEfmtDesc(hgwyLowEfmtDesc);
		profit.setRymtSourGuar(rymtSourGuar);
		profit.setRiskCtlMeas(riskCtlMeas);
		profit.setMdfTm(new Date());
		profit.setMdfUsrId(CurrentThreadContext.getCurrentUserId());
		return profit;
	}

	/**
	 * 修改
	 */
	@RequestMapping(value = "/modify.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object modify(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");
		String name = request.getParameter("name");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_CMM_UPDATE_SUCC);
		if(StringUtils.isEmpty(id)){
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_DATA_PK_IS_EMPTY);
			BaseLogUtils.info(logger, "modify", "修改数据,主键不存在.[id="+id+"]", CurrentThreadContext.getCurrentUserName());
			return result;
		}
		PrjCstProfitAnaVO entity = null;
		try {
			entity = new PrjCstProfitAnaVO();
			entity.setId(Long.valueOf(id));
			//entity.setName(name);
			//TODO ADD PARAM
			boolean success = this.prjCstProfitAnaService.modify(entity);
			if(!success){
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
				BaseLogUtils.info(logger, "modify", "修改失败.[id="+id+"] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
			}
			BaseLogUtils.info(logger, "modify", "修改成功.[id="+id+"] DATA:" + JSONObject.toJSONString(entity), CurrentThreadContext.getCurrentUserName());
		}catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.info(logger, "modify", "修改失败.[id="+id+"] DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.error(logger, "modify", "修改失败.[id="+id+"] DATA:" + JSONObject.toJSONString(entity) + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
		}
		return result;
	}
}

